import java.lang.Thread;
import java.lang.Math;

public class Test21 {
    public static void main(String[] args) {

        Print5 p5 = new Print5();

        p5.start();

        Print6 p6 = new Print6();

        new Thread(p6).start();
    }
}

class Print5 extends Thread {
    public void run() {
        for (int i = 2; i <= 100; i++) {
            boolean flag = IsPrime(i);
            if (flag == true) {
                System.out.println(Thread.currentThread().getName() + ": " + i);
            }

            try {
                int sleepTime = (int)(Math.random() * 1000);
                Thread.sleep(sleepTime);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public boolean IsPrime(int num) {
        for (int i = 2; i < Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }

        return true;
    }
}

class Print6 implements Runnable {
    public void run() {
        for (int i = 20; i >= 1; i--) {
            System.out.println(Thread.currentThread().getName() + ": " + i);

            try {
                int sleepTime = (int)(Math.random() * 1000);
                Thread.sleep(sleepTime);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}